<template>
    <div class="right">
        <div class="header">会员中心-我的等级</div>
        <div class="content" v-loading="loading">
            <div class="top">
                当前等级为<span>{{ computedLevel() }}{{ indesActive }}级</span>
                <div class="button" @click="shengji">立即升级</div>
            </div>
            <div class="bottom">
                <div class="items" v-for="(item, index) in list" :key="index">
                    <div class="label">
                        {{ item.label }}
                    </div>
                    <div class="contentss" v-for="(it, ind) in item.content"
                        :style="{ color: indesActive == it ? 'rgb(255,210,2)' : 'rgb(227, 227, 227)', backgroundColor: indesActive == it ? item.backgroundColor : 'rgb(213, 213, 213)' }">
                        {{ it }}
                        <div class="tops"
                            :style="{ borderBottomColor: indesActive == it ? item.backgroundColor : 'rgb(213, 213, 213)' }">

                        </div>
                        <div class="bottom"
                            :style="{ borderTopColor: indesActive == it ? item.backgroundColor : 'rgb(213, 213, 213)' }">

                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
</template>
<script setup lang="ts">
import { getInfo } from '@/api/index'
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const loading = ref(false)
const indesActive = ref(1)
const list = ref(
    [
        {
            label: '启蒙',
            content: [1, 2, 3],
            backgroundColor: 'rgb(150,232,246)'
        },
        {
            label: '基础',
            content: [4, 5, 6],
            backgroundColor: 'rgb(164,192,232)'
        },
        {
            label: '强化',
            content: [7, 8, 9],
            backgroundColor: 'rgb(219,167,248)'
        },
        {
            label: '提升',
            content: [10, 11, 12],
            backgroundColor: 'rgb(246,156,156)'
        },
    ]
)
/** 计算label文字 */
const computedLevel = () => {
    const indexs = indesActive.value != 0  ? Math.ceil(indesActive.value / 3) - 1 : 0
    return list.value[indexs].label
}
const getList = async () => {
    loading.value = true
    const res = await getInfo()
    indesActive.value = res.data.user.levelId
    loading.value = false
}
const shengji = () =>{
    proxy?.$modal.msgWarning('暂未开放')
}

onMounted(async () => {
    getList()
});
</script>
<style scoped lang="scss">
.right {
    width: calc(100% - 410px);
    height: 100%;

    .header {
        width: 100%;
        padding: 15px 0;
        font-family: Microsoft YaHei;
        font-weight: 400;
        font-size: 18px;
        color: #000000;
        border-bottom: 1px solid #E6E6E6;
    }

    .content {
        width: 100%;
        height: calc(100% - 55px);
        box-sizing: border-box;
        padding: 40px 0 0 0;

        .top {
            width: 100%;
            height: 300px;
            text-align: center;
            font-family: Microsoft YaHei;
            font-weight: 400;
            font-size: 18px;
            color: #000000;
            padding-top: 65px;
            box-sizing: border-box;

            span {
                color: #22AFE5;
                font-size: 36px;
            }

            .button {
                width: 221px;
                height: 44px;
                background: #22AFE5;
                border-radius: 11px 11px 11px 11px;
                text-align: center;
                line-height: 44px;
                font-family: Microsoft YaHei;
                font-weight: 400;
                font-size: 20px;
                color: #FFFFFF;
                margin-left: 50%;
                transform: translateX(-50%);
                margin-top: 70px;
                cursor: pointer;
            }
        }

        .bottom {
            width: 100%;
            height: calc(100% - 300px);
            display: flex;
            align-items: center;
            flex-wrap: wrap;
            justify-content: space-between;

            .items {
                width: 407px;
                height: 144px;
                border: 1px solid rgba(179, 173, 173, 0.2);
                display: flex;
                align-items: center;
                justify-content: space-between;
                margin-bottom: 90px;
                position: relative;
                z-index: 1;
                border-radius: 8px;

                .label {
                    position: absolute;
                    top: -16px;
                    color: rgb(179, 173, 173);
                    font-size: 34px;
                    z-index: 2;
                    width: 88px;
                    text-align: center;
                    background-color: #fff;
                    left: 30px;
                    font-family: Microsoft YaHei;
                    font-weight: 400;
                    font-size: 20px;
                    color: #AAAAAA;
                }

                .contentss {
                    position: relative;
                    width: 66px;
                    /* 六边形的宽度 */
                    height: 40px;
                    /* 六边形的高度 */
                    margin: 50px auto;
                    text-align: center;
                    line-height: 40px;
                    font-size: 50px;
                    font-weight: 800;
                    color: rgb(227, 227, 227);

                    .tops {
                        width: 0;
                        height: 0;
                        border-left: 33px solid transparent;
                        border-right: 33px solid transparent;
                        border-bottom: 15px solid;
                        position: absolute;
                        top: -15px;
                    }

                    .bottom {
                        width: 0;
                        height: 0;
                        border-left: 33px solid transparent;
                        border-right: 33px solid transparent;
                        border-top: 15px solid;
                        position: absolute;
                        top: 40px;
                    }
                }


            }
        }
    }
}
</style>